package com.miyu.client1.utils.alterDiloag;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Controller
public class alter {
    @RequestMapping(value="alert/{module}/{module2}/{name}")
    public String commonController(@PathVariable String module, @PathVariable String module2, @PathVariable String name) {

        return module+"/"+module2+"/"+name;
    }


    @RequestMapping(value="alert/{module}/{name}")
    public String commonController2(@PathVariable String module, @PathVariable String name) {

        return module+"/"+name;
    }

    @RequestMapping(value="alert/{name}")
    public String commonController(@PathVariable String name) {

        return name;
    }

    @RequestMapping(value="fd/{module}/{module2}/{name}")
    public ModelAndView forword(HttpServletRequest request) {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("book/pageBook/magicBookList");
        String bookCode = request.getParameter("bookCode");
        mav.addObject("bookCode",bookCode);
        return mav;
    }
    @RequestMapping(value="fdread/{module}/{module2}/{name}")
    public ModelAndView forword2(HttpServletRequest request) {
        String source = request.getRequestURI();
        source = source.replace("/fdread/readBook/","");
        String bookCode = source.split("/")[0];
        String chapterCod = source.split("/")[1];
        JSONObject data = new JSONObject();
        data.put("bookCode",bookCode);
        data.put("chapterCod",chapterCod);
        ModelAndView mav = new ModelAndView();
        mav.setViewName("book/pageBook/readMagicBook");
        mav.addObject("data",data.toJSONString());
        return mav;
    }

    @RequestMapping(value="fd/{name}")
    public String forword3( @PathVariable String name) {

        return name;
    }



}
